
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>列表页</title>
    <link rel="stylesheet" href="css/style.css" />
</head>
<body>
<input type="files" name="" id="pic">
<img src="" id="m_pic">
</body>
<script type="text/javascript">
   $('#pic').change(function(){
    var size=document.getElementById('pic').files[0].size
    var type=document.getElementById('pic').files[0].type
    if(!/image\/\w+/.test(type)){alert('只能上传图片');return;}
    if(size>1048576){alert('单张图片大小不能大于1M');return;}
    var reader = new FileReader();
    var image='';
    reader.readAsDataURL(document.getElementById('pic').files[0]);
    reader.onload = function(evt){
        document.getElementById('m_pic').src = evt.target.result;
        image = evt.target.result;
        $.ajax({
            url:"xxxxxxx",
            type:'post',
            data:{'image':image},
            dataType:'json',
            success:function(e){
                alert(e.info);
　　　　　　　　　location.reload();
            }
        })
    }
})
</script>
</html>